package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeBaseFamilyMember;
import com.htgd.gardenexpo.dao.GeBaseFamilyMemberDao;
import com.htgd.gardenexpo.service.GeBaseFamilyMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 家庭成员(GeBaseFamilyMember)表服务实现类
 *
 * @author makejava
 * @since 2021-05-31 13:45:06
 */
@Service("geBaseFamilyMemberService")
public class GeBaseFamilyMemberServiceImpl implements GeBaseFamilyMemberService {
    @Resource
    private GeBaseFamilyMemberDao geBaseFamilyMemberDao;

    /**
     * 通过ID查询单条数据
     *
     * @param fid 主键
     * @return 实例对象
     */
    @Override
    public GeBaseFamilyMember queryById(Integer fid) {
        return this.geBaseFamilyMemberDao.queryById(fid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeBaseFamilyMember> queryAllByLimit(int offset, int limit) {
        return this.geBaseFamilyMemberDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param geBaseFamilyMember 实例对象
     * @return 实例对象
     */
    @Override
    public GeBaseFamilyMember insert(GeBaseFamilyMember geBaseFamilyMember) {
        this.geBaseFamilyMemberDao.insert(geBaseFamilyMember);
        return geBaseFamilyMember;
    }

    /**
     * 修改数据
     *
     * @param geBaseFamilyMember 实例对象
     * @return 实例对象
     */
    @Override
    public GeBaseFamilyMember update(GeBaseFamilyMember geBaseFamilyMember) {
        this.geBaseFamilyMemberDao.update(geBaseFamilyMember);
        return this.queryById(geBaseFamilyMember.getFid());
    }

    /**
     * 通过主键删除数据
     *
     * @param fid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer fid) {
        return this.geBaseFamilyMemberDao.deleteById(fid) > 0;
    }
}
